/*
	FileName : app_led.c
	Description : 
	
	Created on 2013.10.27 by ZZP.
	
	Revision History:
	
*/

#include "bsp.h"
#include "app.h"
#include "app_led.h"


void LedHandler(void)
{
	//LED_WORK
    if ((AppInfo.WorkLedTm % 40)   == 0)
    {
        BSP_LED_On(LED_WORK);
		AppInfo.WorkLedTm = 0;
    }
    else if ((AppInfo.WorkLedTm % 15) == 0)
   	{
   		BSP_LED_Off(LED_WORK);
	}
	AppInfo.WorkLedTm++;

	

	if (AppInfo.UsartRxFlag[COM1])
	{	
		if (AppInfo.RxLedTm >= 16)
		{	
			BSP_LED_Off(LED_USART_RX);
			
			AppInfo.RxLedTm = 0;
			
			AppInfo.UsartRxFlag[COM1]--;
		}
		else
		{	
			if ((AppInfo.RxLedTm % 8) == 0)
			{
				BSP_LED_On(LED_USART_RX);
			}
			else if ((AppInfo.RxLedTm % 4) == 0)
			{
				 BSP_LED_Off(LED_USART_RX);
			}
			
			AppInfo.RxLedTm++;
		}
	}
	else
	{
		BSP_LED_Off(LED_USART_RX);
		
		AppInfo.RxLedTm = 0;
	}

	if (AppInfo.UsartTxFlag[COM1])
	{	
		if (AppInfo.TxLedTm >= 16)
		{	
			BSP_LED_Off(LED_USART_TX);
			AppInfo.TxLedTm = 0;
			AppInfo.UsartTxFlag[COM1]--;
		}
		else
		{	
			if ((AppInfo.TxLedTm % 8) == 0)
			{
				BSP_LED_On(LED_USART_TX);
			}
			else if ((AppInfo.TxLedTm % 4) == 0)
			{
			    BSP_LED_Off(LED_USART_TX);
			}
			
			AppInfo.TxLedTm++;
		}
	}
	else
	{
		BSP_LED_Off(LED_USART_TX);
		
		AppInfo.TxLedTm = 0;
	}

}





